package com.ssm.service.impl;

import com.ssm.dao.AirTicketDao;
import com.ssm.pojo.AirTicket;
import com.ssm.pojo.PageInfo;
import com.ssm.service.AirTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AirTicketServiceImpl implements AirTicketService{

    @Autowired
    private AirTicketDao airTicketDao;

    @Override
    public PageInfo<AirTicket> getUserList(AirTicket airTicket, int pageNum, int pageSize) {
        Integer count = airTicketDao.getAirTicketCount(airTicket);
        PageInfo<AirTicket> pageInfo = new PageInfo<>();
        pageInfo.setTotalCount(count);
        pageInfo.setPageSize(pageSize);
        pageInfo.setPageNum(pageNum);
        if (count > 0) {
            airTicket.setPageSize(pageSize);
            airTicket.setOffset((pageNum - 1) * pageSize);
            List<AirTicket> users = airTicketDao.getAirTicket(airTicket);
            pageInfo.setResult(users);
        }
        return pageInfo;
    }
}
